/**
 * @author Burcak Otlu Saritas
 *
 * 
 */



package annotate.intervals.parametric;

import intervaltree.Interval;
import intervaltree.IntervalTree;
import intervaltree.IntervalTreeNode;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import annotate.encode.Commons;

public class AnnotateGivenIntervalsWithGivenParameters {

	public void createChromBaseSeachInputFiles(List<BufferedWriter> bufferedWriterList){
		try {
			FileWriter fileWriter1 	= new FileWriter(Commons.SEARCH_CHR1_INPUT_FILE);
			FileWriter fileWriter2 	= new FileWriter(Commons.SEARCH_CHR2_INPUT_FILE);
			FileWriter fileWriter3 	= new FileWriter(Commons.SEARCH_CHR3_INPUT_FILE);
			FileWriter fileWriter4 	= new FileWriter(Commons.SEARCH_CHR4_INPUT_FILE);
			FileWriter fileWriter5 	= new FileWriter(Commons.SEARCH_CHR5_INPUT_FILE);
			FileWriter fileWriter6 	= new FileWriter(Commons.SEARCH_CHR6_INPUT_FILE);
			FileWriter fileWriter7	= new FileWriter(Commons.SEARCH_CHR7_INPUT_FILE);
			FileWriter fileWriter8 	= new FileWriter(Commons.SEARCH_CHR8_INPUT_FILE);
			FileWriter fileWriter9 	= new FileWriter(Commons.SEARCH_CHR9_INPUT_FILE);
			FileWriter fileWriter10 = new FileWriter(Commons.SEARCH_CHR10_INPUT_FILE);
			FileWriter fileWriter11 = new FileWriter(Commons.SEARCH_CHR11_INPUT_FILE);
			FileWriter fileWriter12 = new FileWriter(Commons.SEARCH_CHR12_INPUT_FILE);
			FileWriter fileWriter13 = new FileWriter(Commons.SEARCH_CHR13_INPUT_FILE);
			FileWriter fileWriter14 = new FileWriter(Commons.SEARCH_CHR14_INPUT_FILE);
			FileWriter fileWriter15 = new FileWriter(Commons.SEARCH_CHR15_INPUT_FILE);
			FileWriter fileWriter16 = new FileWriter(Commons.SEARCH_CHR16_INPUT_FILE);
			FileWriter fileWriter17 = new FileWriter(Commons.SEARCH_CHR17_INPUT_FILE);
			FileWriter fileWriter18 = new FileWriter(Commons.SEARCH_CHR18_INPUT_FILE);
			FileWriter fileWriter19 = new FileWriter(Commons.SEARCH_CHR19_INPUT_FILE);
			FileWriter fileWriter20 = new FileWriter(Commons.SEARCH_CHR20_INPUT_FILE);
			FileWriter fileWriter21 = new FileWriter(Commons.SEARCH_CHR21_INPUT_FILE);
			FileWriter fileWriter22 = new FileWriter(Commons.SEARCH_CHR22_INPUT_FILE);
			FileWriter fileWriter23 = new FileWriter(Commons.SEARCH_CHRX_INPUT_FILE);
			FileWriter fileWriter24 = new FileWriter(Commons.SEARCH_CHRY_INPUT_FILE);
			
			BufferedWriter bufferedWriter1 	= new BufferedWriter(fileWriter1);
			BufferedWriter bufferedWriter2 	= new BufferedWriter(fileWriter2);
			BufferedWriter bufferedWriter3 	= new BufferedWriter(fileWriter3);
			BufferedWriter bufferedWriter4 	= new BufferedWriter(fileWriter4);
			BufferedWriter bufferedWriter5 	= new BufferedWriter(fileWriter5);
			BufferedWriter bufferedWriter6 	= new BufferedWriter(fileWriter6);
			BufferedWriter bufferedWriter7 	= new BufferedWriter(fileWriter7);
			BufferedWriter bufferedWriter8 	= new BufferedWriter(fileWriter8);
			BufferedWriter bufferedWriter9 	= new BufferedWriter(fileWriter9);
			BufferedWriter bufferedWriter10 = new BufferedWriter(fileWriter10);
			BufferedWriter bufferedWriter11 = new BufferedWriter(fileWriter11);
			BufferedWriter bufferedWriter12 = new BufferedWriter(fileWriter12);
			BufferedWriter bufferedWriter13 = new BufferedWriter(fileWriter13);
			BufferedWriter bufferedWriter14 = new BufferedWriter(fileWriter14);
			BufferedWriter bufferedWriter15 = new BufferedWriter(fileWriter15);
			BufferedWriter bufferedWriter16 = new BufferedWriter(fileWriter16);
			BufferedWriter bufferedWriter17 = new BufferedWriter(fileWriter17);
			BufferedWriter bufferedWriter18 = new BufferedWriter(fileWriter18);
			BufferedWriter bufferedWriter19 = new BufferedWriter(fileWriter19);
			BufferedWriter bufferedWriter20 = new BufferedWriter(fileWriter20);
			BufferedWriter bufferedWriter21 = new BufferedWriter(fileWriter21);
			BufferedWriter bufferedWriter22 = new BufferedWriter(fileWriter22);
			BufferedWriter bufferedWriter23 = new BufferedWriter(fileWriter23);
			BufferedWriter bufferedWriter24 = new BufferedWriter(fileWriter24);
			
			bufferedWriterList.add(bufferedWriter1);
			bufferedWriterList.add(bufferedWriter2);
			bufferedWriterList.add(bufferedWriter3);
			bufferedWriterList.add(bufferedWriter4);
			bufferedWriterList.add(bufferedWriter5);
			bufferedWriterList.add(bufferedWriter6);
			bufferedWriterList.add(bufferedWriter7);
			bufferedWriterList.add(bufferedWriter8);
			bufferedWriterList.add(bufferedWriter9);
			bufferedWriterList.add(bufferedWriter10);
			bufferedWriterList.add(bufferedWriter11);
			bufferedWriterList.add(bufferedWriter12);
			bufferedWriterList.add(bufferedWriter13);
			bufferedWriterList.add(bufferedWriter14);
			bufferedWriterList.add(bufferedWriter15);
			bufferedWriterList.add(bufferedWriter16);
			bufferedWriterList.add(bufferedWriter17);
			bufferedWriterList.add(bufferedWriter18);
			bufferedWriterList.add(bufferedWriter19);
			bufferedWriterList.add(bufferedWriter20);
			bufferedWriterList.add(bufferedWriter21);
			bufferedWriterList.add(bufferedWriter22);
			bufferedWriterList.add(bufferedWriter23);
			bufferedWriterList.add(bufferedWriter24);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	
	public void writeChromBaseSearchInputFile(String chromName, String strLine, List<BufferedWriter> bufList){
		try {
			
			if (chromName.equals(Commons.CHROMOSOME1)){
				bufList.get(0).write(strLine + "\n");
				bufList.get(0).flush();		
			} else 	if (chromName.equals(Commons.CHROMOSOME2)){
				bufList.get(1).write(strLine + "\n");
				bufList.get(1).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME3)){
				bufList.get(2).write(strLine + "\n");
				bufList.get(2).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME4)){
				bufList.get(3).write(strLine + "\n");
				bufList.get(3).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME5)){
				bufList.get(4).write(strLine + "\n");
				bufList.get(4).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME6)){
				bufList.get(5).write(strLine + "\n");
				bufList.get(5).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME7)){
				bufList.get(6).write(strLine + "\n");
				bufList.get(6).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME8)){
				bufList.get(7).write(strLine + "\n");
				bufList.get(7).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME9)){
				bufList.get(8).write(strLine + "\n");
				bufList.get(8).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME10)){
				bufList.get(9).write(strLine + "\n");
				bufList.get(9).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME11)){
				bufList.get(10).write(strLine + "\n");
				bufList.get(10).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME12)){
				bufList.get(11).write(strLine + "\n");
				bufList.get(11).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME13)){
				bufList.get(12).write(strLine + "\n");
				bufList.get(12).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME14)){
				bufList.get(13).write(strLine + "\n");
				bufList.get(13).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME15)){
				bufList.get(14).write(strLine + "\n");
				bufList.get(14).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME16)){
				bufList.get(15).write(strLine + "\n");
				bufList.get(15).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME17)){
				bufList.get(16).write(strLine + "\n");
				bufList.get(16).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME18)){
				bufList.get(17).write(strLine + "\n");
				bufList.get(17).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME19)){
				bufList.get(18).write(strLine + "\n");
				bufList.get(18).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME20)){
				bufList.get(19).write(strLine + "\n");
				bufList.get(19).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME21)){
				bufList.get(20).write(strLine + "\n");
				bufList.get(20).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOME22)){
				bufList.get(21).write(strLine + "\n");
				bufList.get(21).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOMEX)){
				bufList.get(22).write(strLine + "\n");
				bufList.get(22).flush();		
			}else 	if (chromName.equals(Commons.CHROMOSOMEY)){
				bufList.get(23).write(strLine + "\n");
				bufList.get(23).flush();		
			}else{
				System.out.println("Unknown chromosome");
			}

		
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void partitionSearchInputFilePerChromName(String inputFileName, List<BufferedWriter> bufferedWriterList){
		
		FileReader fileReader = null;
		BufferedReader bufferedReader = null;
		
		String strLine;
		int indexofFirstTab;
		String chromName;
		
		try {
			fileReader = new FileReader(inputFileName);
			bufferedReader = new BufferedReader(fileReader);
			
			while((strLine=bufferedReader.readLine())!=null){
				
				indexofFirstTab = strLine.indexOf('\t');
				chromName = strLine.substring(0,indexofFirstTab);
				writeChromBaseSearchInputFile(chromName,strLine,bufferedWriterList);
				
			} // End of While
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		try {
			bufferedReader.close();
			fileReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}				
	}
	
	
	public IntervalTree generateEncodeDnaseIntervalTree(BufferedReader bufferedReader, Map<String,Integer> dnaseCellLineNameHashMap) {
		IntervalTree dnaseIntervalTree = new IntervalTree();
		String strLine = null;
		
		int indexofFirstTab = 0;
		int indexofSecondTab = 0;
		int indexofThirdTab = 0;
		int indexofFourthTab = 0;
		
		int startPosition = 0;
		int endPosition = 0;
		
		String chromName;
		String cellLineName;
		String fileName;
		
		
		
		try {
			while((strLine = bufferedReader.readLine())!=null){
//				example strLine
//				chr1	91852781	91853156	GM12878	idrPool.GM12878-DS9432-DS10671.z_OV_GM12878-DS10671.z_VS_GM12878-DS9432.z.npk2.narrowPeak

				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t', indexofFirstTab+1);
				indexofThirdTab = strLine.indexOf('\t', indexofSecondTab+1);
				indexofFourthTab = strLine.indexOf('\t', indexofThirdTab+1);
					
				chromName = strLine.substring(0,indexofFirstTab);
				
				startPosition = Integer.parseInt(strLine.substring(indexofFirstTab+1,indexofSecondTab));
				endPosition = Integer.parseInt(strLine.substring(indexofSecondTab+1, indexofThirdTab));
				
				cellLineName = strLine.substring(indexofThirdTab+1, indexofFourthTab);
								
				fileName = strLine.substring(indexofFourthTab+1);
				
//				if dnase exists in dnaseList 
				if (dnaseCellLineNameHashMap.containsKey(cellLineName)){
//					Creating millions of nodes with six attributes causes out of memory error
//					IntervalTreeNode node = new IntervalTreeNode(chromName.toCharArray(),startPosition,endPosition,cellLineName.toCharArray(),fileName.toCharArray());
					IntervalTreeNode node = new IntervalTreeNode(chromName,startPosition,endPosition,cellLineName,fileName);
					dnaseIntervalTree.intervalTreeInsert(dnaseIntervalTree, node);						
				} //End of If	
				
				chromName = null;
				cellLineName = null;
				fileName = null;				
				strLine = null;
				
			} // End of While 
		} catch (IOException e) {
			e.printStackTrace();
		}

		return dnaseIntervalTree;
	}
	
	public IntervalTree generateEncodeTfbsIntervalTree(BufferedReader bufferedReader, Map<String,Integer> tfbsNameHashMap){
		IntervalTree tfbsIntervalTree = new IntervalTree();
		String strLine;
		
		int indexofFirstTab = 0;
		int indexofSecondTab = 0;
		int indexofThirdTab = 0;
		int indexofFourthTab = 0;
		int indexofFifthTab = 0;
		
		int startPosition = 0;
		int endPosition = 0;
		
		String chromName;
		String tfbsName;
		String cellLineName;
		String fileName;
		
	  
	    
		try {
			while((strLine = bufferedReader.readLine())!=null){
//				exampple strLine
//				chrY	2804079	2804213	Ctcf	H1hesc	spp.optimal.wgEncodeBroadHistoneH1hescCtcfStdAlnRep0_VS_wgEncodeBroadHistoneH1hescControlStdAlnRep0.narrowPeak
			
				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t', indexofFirstTab+1);
				indexofThirdTab = strLine.indexOf('\t', indexofSecondTab+1);
				indexofFourthTab = strLine.indexOf('\t', indexofThirdTab+1);
				indexofFifthTab = strLine.indexOf('\t', indexofFourthTab+1);
					
				chromName = strLine.substring(0,indexofFirstTab);
				
				startPosition = Integer.parseInt(strLine.substring(indexofFirstTab+1,indexofSecondTab));
				endPosition = Integer.parseInt(strLine.substring(indexofSecondTab+1, indexofThirdTab));
				
				tfbsName = strLine.substring(indexofThirdTab+1, indexofFourthTab);
				
				cellLineName = strLine.substring(indexofFourthTab+1, indexofFifthTab);
				
				fileName = strLine.substring(indexofFifthTab+1);

//				if tfbs exists in tfbsList 
				if (tfbsNameHashMap.containsKey(tfbsName)){
//					Creating millions of nodes with six attributes causes out of memory error
//					IntervalTreeNode node = new IntervalTreeNode(chromName.toCharArray(),startPosition,endPosition,tfbsName.toCharArray(),cellLineName.toCharArray(),fileName.toCharArray());
					IntervalTreeNode node = new IntervalTreeNode(chromName,startPosition,endPosition,tfbsName,cellLineName,fileName);
					tfbsIntervalTree.intervalTreeInsert(tfbsIntervalTree, node);					
				}
				
				chromName = null;
				tfbsName = null;
				cellLineName = null;
				fileName = null;
				strLine = null;
								
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return tfbsIntervalTree;
	}

	public IntervalTree generateEncodeHistoneIntervalTree(BufferedReader bufferedReader, Map<String,Integer> histoneNameHashMap) {
		IntervalTree histoneIntervalTree = new IntervalTree();
		String strLine;
		
		int indexofFirstTab = 0;
		int indexofSecondTab = 0;
		int indexofThirdTab = 0;
		int indexofFourthTab = 0;
		int indexofFifthTab = 0;
				
		String chromName;
		int startPosition = 0;
		int endPosition = 0;
		
		String histoneName;
		String cellLineName;
		String fileName;
		
	
		try {
			while((strLine = bufferedReader.readLine())!=null){
//				example strLine
//				chr9	131533188	131535395	H2az	Gm12878	wgEncodeBroadHistoneGm12878H2azStdAln.narrowPeak

				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t', indexofFirstTab+1);
				indexofThirdTab = strLine.indexOf('\t', indexofSecondTab+1);
				indexofFourthTab = strLine.indexOf('\t', indexofThirdTab+1);
				indexofFifthTab = strLine.indexOf('\t', indexofFourthTab+1);
					
				chromName = strLine.substring(0,indexofFirstTab);
				
				startPosition = Integer.parseInt(strLine.substring(indexofFirstTab+1,indexofSecondTab));
				endPosition = Integer.parseInt(strLine.substring(indexofSecondTab+1, indexofThirdTab));
				
				
				histoneName = strLine.substring(indexofThirdTab+1, indexofFourthTab);
				
				cellLineName = strLine.substring(indexofFourthTab+1, indexofFifthTab);
				
				fileName = strLine.substring(indexofFifthTab+1);
				
				if (histoneNameHashMap.containsKey(histoneName)){
//					Creating millions of nodes with six attributes causes out of memory error
//					IntervalTreeNode node = new IntervalTreeNode(chromName.toCharArray(),startPosition,endPosition,histoneName.toCharArray(),cellLineName.toCharArray(),fileName.toCharArray());
					IntervalTreeNode node = new IntervalTreeNode(chromName,startPosition,endPosition,histoneName,cellLineName,fileName);
					histoneIntervalTree.intervalTreeInsert(histoneIntervalTree, node);				
				}
				
				chromName = null;
				histoneName  = null;
				cellLineName = null;
				fileName = null;
				strLine = null;
								
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return histoneIntervalTree;
	}

	public IntervalTree generateUcscRefSeqGenesIntervalTree(BufferedReader bufferedReader){
		IntervalTree tree = new IntervalTree();
		String strLine;
		
		int indexofFirstTab = 0;
		int indexofSecondTab = 0;
		int indexofThirdTab = 0;
		int indexofFourthTab = 0;
		int indexofFifthTab = 0;
		int indexofSixthTab = 0;
		int indexofSeventhTab = 0;
		
		int startPosition = 0;
		int endPosition = 0;
		
		String chromName;
		String  refSeqGeneName;
		Integer geneEntrezId;
		String intervalName;
		String geneHugoSymbol;		
		
		
		try {
			while((strLine = bufferedReader.readLine())!=null){
//				example strLine
//				chr17	67074846	67075215	NM_080284	23460	Exon1	-	ABCA6

				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t', indexofFirstTab+1);
				indexofThirdTab = strLine.indexOf('\t', indexofSecondTab+1);
				indexofFourthTab = strLine.indexOf('\t', indexofThirdTab+1);
				indexofFifthTab = strLine.indexOf('\t', indexofFourthTab+1);
				indexofSixthTab = strLine.indexOf('\t', indexofFifthTab+1);
				indexofSeventhTab = strLine.indexOf('\t',indexofSixthTab+1);	
				
				chromName = strLine.substring(0,indexofFirstTab);
				
				startPosition = Integer.parseInt(strLine.substring(indexofFirstTab+1,indexofSecondTab));
				endPosition = Integer.parseInt(strLine.substring(indexofSecondTab+1, indexofThirdTab));
				
				refSeqGeneName = strLine.substring(indexofThirdTab+1, indexofFourthTab);
				
				geneEntrezId = Integer.parseInt(strLine.substring(indexofFourthTab+1, indexofFifthTab));
				
				intervalName = strLine.substring(indexofFifthTab+1, indexofSixthTab);
				
				geneHugoSymbol = strLine.substring(indexofSeventhTab+1);
				
//				Creating millions of nodes with seven attributes causes out of memory error
//				IntervalTreeNode node = new IntervalTreeNode(chromName.toCharArray(),startPosition,endPosition,refSeqGeneName.toCharArray(),geneEntrezId,intervalName.toCharArray(),geneHugoSymbol.toCharArray());
				IntervalTreeNode node = new IntervalTreeNode(chromName,startPosition,endPosition,refSeqGeneName,geneEntrezId,intervalName,geneHugoSymbol);
				tree.intervalTreeInsert(tree, node);
				
				chromName = null;
				refSeqGeneName = null;
				geneEntrezId = null;
				intervalName = null;
				geneHugoSymbol = null;
				strLine = null;
			}// end of While
		} catch (IOException e) {
			e.printStackTrace();
		}
				
		return tree;
	}

	
		
	
	public IntervalTree createDnaseIntervalTree(String chromName, Map<String,Integer> dnaseCellLineNameHashMap){
		IntervalTree  dnaseIntervalTree =null;
		FileReader fileReader =null;
		BufferedReader bufferedReader = null;
		
		try {			
			if (Commons.CHROMOSOME1.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR1_DNASE);				
			} else if (Commons.CHROMOSOME2.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR2_DNASE);				
			} else if (Commons.CHROMOSOME3.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR3_DNASE);				
			} else if (Commons.CHROMOSOME4.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR4_DNASE);				
			} else if (Commons.CHROMOSOME5.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR5_DNASE);				
			} else if (Commons.CHROMOSOME6.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR6_DNASE);				
			} else if (Commons.CHROMOSOME7.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR7_DNASE);				
			} else if (Commons.CHROMOSOME8.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR8_DNASE);				
			} else if (Commons.CHROMOSOME9.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR9_DNASE);				
			} else if (Commons.CHROMOSOME10.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR10_DNASE);				
			} else if (Commons.CHROMOSOME11.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR11_DNASE);				
			} else if (Commons.CHROMOSOME12.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR12_DNASE);				
			} else if (Commons.CHROMOSOME13.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR13_DNASE);				
			} else if (Commons.CHROMOSOME14.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR14_DNASE);				
			} else if (Commons.CHROMOSOME15.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR15_DNASE);				
			} else if (Commons.CHROMOSOME16.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR16_DNASE);				
			} else if (Commons.CHROMOSOME17.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR17_DNASE);				
			} else if (Commons.CHROMOSOME18.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR18_DNASE);				
			} else if (Commons.CHROMOSOME19.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR19_DNASE);				
			} else if (Commons.CHROMOSOME20.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR20_DNASE);				
			} else if (Commons.CHROMOSOME21.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR21_DNASE);				
			} else if (Commons.CHROMOSOME22.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR22_DNASE);				
			} else if (Commons.CHROMOSOMEX.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHRX_DNASE);				
			} else if (Commons.CHROMOSOMEY.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHRY_DNASE);				
			} 
		
			bufferedReader = new BufferedReader(fileReader);
			dnaseIntervalTree = generateEncodeDnaseIntervalTree(bufferedReader,dnaseCellLineNameHashMap);
			
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		
		return dnaseIntervalTree;
	}

	public IntervalTree createTfbsIntervalTree(String chromName, Map<String,Integer> tfbsNameHashMap){
		IntervalTree  tfbsIntervalTree =null;
		FileReader fileReader =null;
		BufferedReader bufferedReader = null;
		
		try {			
			if (Commons.CHROMOSOME1.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR1_TFBS);				
			} else if (Commons.CHROMOSOME2.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR2_TFBS);				
			} else if (Commons.CHROMOSOME3.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR3_TFBS);				
			} else if (Commons.CHROMOSOME4.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR4_TFBS);				
			} else if (Commons.CHROMOSOME5.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR5_TFBS);				
			} else if (Commons.CHROMOSOME6.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR6_TFBS);				
			} else if (Commons.CHROMOSOME7.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR7_TFBS);				
			} else if (Commons.CHROMOSOME8.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR8_TFBS);				
			} else if (Commons.CHROMOSOME9.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR9_TFBS);				
			} else if (Commons.CHROMOSOME10.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR10_TFBS);				
			} else if (Commons.CHROMOSOME11.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR11_TFBS);				
			} else if (Commons.CHROMOSOME12.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR12_TFBS);				
			} else if (Commons.CHROMOSOME13.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR13_TFBS);				
			} else if (Commons.CHROMOSOME14.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR14_TFBS);				
			} else if (Commons.CHROMOSOME15.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR15_TFBS);				
			} else if (Commons.CHROMOSOME16.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR16_TFBS);				
			} else if (Commons.CHROMOSOME17.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR17_TFBS);				
			} else if (Commons.CHROMOSOME18.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR18_TFBS);				
			} else if (Commons.CHROMOSOME19.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR19_TFBS);				
			} else if (Commons.CHROMOSOME20.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR20_TFBS);				
			} else if (Commons.CHROMOSOME21.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR21_TFBS);				
			} else if (Commons.CHROMOSOME22.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR22_TFBS);				
			} else if (Commons.CHROMOSOMEX.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHRX_TFBS);				
			} else if (Commons.CHROMOSOMEY.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHRY_TFBS);				
			} 
		
			bufferedReader = new BufferedReader(fileReader);
			tfbsIntervalTree = generateEncodeTfbsIntervalTree(bufferedReader,tfbsNameHashMap);
			
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}		
		
		return tfbsIntervalTree;	
	}

	
	public IntervalTree createHistoneIntervalTree(String chromName,Map<String,Integer> histoneNameHashMap){
		IntervalTree  histoneIntervalTree =null;
		FileReader fileReader =null;
		BufferedReader bufferedReader = null;
		
		try {			
			if (Commons.CHROMOSOME1.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR1_HISTONE);				
			} else if (Commons.CHROMOSOME2.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR2_HISTONE);				
			} else if (Commons.CHROMOSOME3.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR3_HISTONE);				
			} else if (Commons.CHROMOSOME4.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR4_HISTONE);				
			} else if (Commons.CHROMOSOME5.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR5_HISTONE);				
			} else if (Commons.CHROMOSOME6.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR6_HISTONE);				
			} else if (Commons.CHROMOSOME7.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR7_HISTONE);				
			} else if (Commons.CHROMOSOME8.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR8_HISTONE);				
			} else if (Commons.CHROMOSOME9.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR9_HISTONE);				
			} else if (Commons.CHROMOSOME10.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR10_HISTONE);				
			} else if (Commons.CHROMOSOME11.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR11_HISTONE);				
			} else if (Commons.CHROMOSOME12.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR12_HISTONE);				
			} else if (Commons.CHROMOSOME13.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR13_HISTONE);				
			} else if (Commons.CHROMOSOME14.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR14_HISTONE);				
			} else if (Commons.CHROMOSOME15.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR15_HISTONE);				
			} else if (Commons.CHROMOSOME16.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR16_HISTONE);				
			} else if (Commons.CHROMOSOME17.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR17_HISTONE);				
			} else if (Commons.CHROMOSOME18.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR18_HISTONE);				
			} else if (Commons.CHROMOSOME19.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR19_HISTONE);				
			} else if (Commons.CHROMOSOME20.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR20_HISTONE);				
			} else if (Commons.CHROMOSOME21.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR21_HISTONE);				
			} else if (Commons.CHROMOSOME22.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHR22_HISTONE);				
			} else if (Commons.CHROMOSOMEX.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHRX_HISTONE);				
			} else if (Commons.CHROMOSOMEY.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_ENCODE_UNSORTED_CHRY_HISTONE);				
			} 
		
			bufferedReader = new BufferedReader(fileReader);
			histoneIntervalTree = generateEncodeHistoneIntervalTree(bufferedReader,histoneNameHashMap);
			
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}		
		
		return histoneIntervalTree;	
	}
	
	public IntervalTree createUcscRefSeqGenesIntervalTree(String chromName){
		IntervalTree  ucscRefSeqGenesIntervalTree =null;
		FileReader fileReader =null;
		BufferedReader bufferedReader = null;
		
		try {			
			if (Commons.CHROMOSOME1.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR1_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME2.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR2_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME3.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR3_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME4.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR4_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME5.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR5_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME6.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR6_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME7.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR7_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME8.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR8_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME9.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR9_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME10.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR10_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME11.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR11_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME12.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR12_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME13.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR13_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME14.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR14_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME15.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR15_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME16.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR16_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME17.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR17_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME18.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR18_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME19.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR19_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME20.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR20_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME21.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR21_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOME22.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHR22_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOMEX.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHRX_REFSEQ_GENES);				
			} else if (Commons.CHROMOSOMEY.equals(chromName)){
					fileReader = new FileReader(Commons.C_ECLIPSE_GANYMEDE_WORKSPACE_DOKTORA_ANNOTATE_UCSCGENOME_UNSORTED_CHRY_REFSEQ_GENES);				
			} 
		
			bufferedReader = new BufferedReader(fileReader);
			ucscRefSeqGenesIntervalTree = generateUcscRefSeqGenesIntervalTree(bufferedReader);
			
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}		
		
		return ucscRefSeqGenesIntervalTree;	
	
	}

	


	
	public void searchDnase(String chromName,BufferedReader bufferedReader, IntervalTree dnaseIntervalTree, Map<String,BufferedWriter> dnaseBufferedWriterHashMap,Map<String,Integer> dnaseCellLineNameHashMap){
		String strLine = null;
		int indexofFirstTab = 0 ;
		int indexofSecondTab = 0;
		
		int low;
		int high;
		
		try {
			while((strLine = bufferedReader.readLine())!=null){
				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t',indexofFirstTab+1);
				
				low = Integer.parseInt(strLine.substring(indexofFirstTab+1, indexofSecondTab));
				
//				indexofSecondTab must be greater than zero if it exists since indexofFirstTab must exists and can be at least zero therefore indexofSecondTab can be at least one.
				if (indexofSecondTab>0)
					high = Integer.parseInt(strLine.substring(indexofSecondTab+1));
				else 
					high = low;
				
				
				Interval interval = new Interval(low,high);
//				todo in which file will it be written
//				bufferedWriter.write("Searched for" + "\t" + chromName + "\t" + low + "\t" + high + "\n");
//				bufferedWriter.flush();				
//				dnaseIntervalTree.findAllOverlappingDnaseIntervals(dnaseIntervalTree.getRoot(),interval,chromName, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
				dnaseIntervalTree.findFirstOverlappingDnaseInterval(dnaseIntervalTree.getRoot(),interval,chromName, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
				

			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} // End of while 
			
	}


	public void searchTfbs(String chromName, BufferedReader bufferedReader, IntervalTree tfbsIntervalTree, Map<String,BufferedWriter> tfbsBufferedWriterHashMap, Map<String,Integer> tfbsNameHashMap){
		String strLine = null;
		int indexofFirstTab = 0;
		int indexofSecondTab = 0;
		
		int low;
		int high;
		
	
		try {
			while((strLine = bufferedReader.readLine())!=null){
				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t',indexofFirstTab+1);
				
				low = Integer.parseInt(strLine.substring(indexofFirstTab+1, indexofSecondTab));
				
//				indexofSecondTab must be greater than zero if it exists since indexofFirstTab must exists and can be at least zero therefore indexofSecondTab can be at least one.
				if (indexofSecondTab>0)
					high = Integer.parseInt(strLine.substring(indexofSecondTab+1));
				else 
					high = low;
				
				Interval interval = new Interval(low,high);
//				todo later
//				bufferedWriter.write("Searched for" + "\t" + chromName + "\t" + low + "\t" + high + "\n");
//				bufferedWriter.flush();	
				
				tfbsIntervalTree.findAllOverlappingTfbsIntervals(tfbsIntervalTree.getRoot(),interval,chromName,tfbsBufferedWriterHashMap,tfbsNameHashMap);
				tfbsIntervalTree.findFirstOverlappingTfbsInterval(tfbsIntervalTree.getRoot(),interval,chromName,tfbsBufferedWriterHashMap,tfbsNameHashMap);

			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} // End of while 
	}
	

	
	public void searchHistone(String chromName, BufferedReader bufferedReader, IntervalTree histoneIntervalTree, Map<String,BufferedWriter> histoneBufferedWriterHashMap, Map<String,Integer> histoneNameHashMap){
		String strLine = null;
		int indexofFirstTab = 0;
		int indexofSecondTab = 0;
		
		int low;
		int high;
		
		try {
			while((strLine = bufferedReader.readLine())!=null){
				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t',indexofFirstTab+1);
				
				low = Integer.parseInt(strLine.substring(indexofFirstTab+1, indexofSecondTab));
				
//				indexofSecondTab must be greater than zero if it exists since indexofFirstTab must exists and can be at least zero therefore indexofSecondTab can be at least one.
				if (indexofSecondTab>0)
					high = Integer.parseInt(strLine.substring(indexofSecondTab+1));
				else 
					high = low;
				
				Interval interval = new Interval(low,high);
//				todo
//				bufferedWriter.write("Searched for" + "\t" + chromName + "\t" + low + "\t" + high + "\n");
//				bufferedWriter.flush();				
//				histoneIntervalTree.findAllOverlappingHistoneIntervals(histoneIntervalTree.getRoot(),interval,chromName, histoneBufferedWriterHashMap,histoneNameHashMap);
				histoneIntervalTree.findFirstOverlappingHistoneInterval(histoneIntervalTree.getRoot(),interval,chromName, histoneBufferedWriterHashMap,histoneNameHashMap);

			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} // End of while 
	}
	

	
	//Search keggPathway
	public void searchUcscRefSeqGenes(String chromName, BufferedReader bufferedReader, IntervalTree ucscRefSeqGenesIntervalTree, Map<String,BufferedWriter> bufferedWriterHashMap, Map<String,Integer> keggPathwayNameHashMap, List<KeggPathway> keggPathwayList, List<String> nameorIdList, String type){
		String strLine = null;
		int indexofFirstTab = 0;
		int indexofSecondTab = 0;
		
		int low;
		int high;
		
		try {
			while((strLine = bufferedReader.readLine())!=null){
				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t',indexofFirstTab+1);
				
				low = Integer.parseInt(strLine.substring(indexofFirstTab+1, indexofSecondTab));
				
//				indexofSecondTab must be greater than zero if it exists since indexofFirstTab must exists and can be at least zero therefore indexofSecondTab can be at least one.
				if (indexofSecondTab>0)
					high = Integer.parseInt(strLine.substring(indexofSecondTab+1));
				else 
					high = low;
				
				Interval interval = new Interval(low,high);
//				todo
//				bufferedWriter.write("Searched for" + "\t" + chromName + "\t" + low + "\t" + high + "\n");
//				bufferedWriter.flush();				
				ucscRefSeqGenesIntervalTree.findAllOverlappingUcscRefSeqGenesIntervals(ucscRefSeqGenesIntervalTree.getRoot(),interval,chromName,bufferedWriterHashMap,keggPathwayNameHashMap,keggPathwayList,nameorIdList,type);
				
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} // End of while 
	}

	
	
	

	public void searchUcscRefSeqGenes(String chromName, BufferedReader bufferedReader, IntervalTree ucscRefSeqGenesIntervalTree, Map<String,BufferedWriter> bufferedWriterHashMap, Map<String,Integer> nameorIdHashMap, String type){
		String strLine = null;
		int indexofFirstTab = 0;
		int indexofSecondTab = 0;
		
		int low;
		int high;
		
		try {
			while((strLine = bufferedReader.readLine())!=null){
				indexofFirstTab = strLine.indexOf('\t');
				indexofSecondTab = strLine.indexOf('\t',indexofFirstTab+1);
				
				low = Integer.parseInt(strLine.substring(indexofFirstTab+1, indexofSecondTab));
				
//				indexofSecondTab must be greater than zero if it exists since indexofFirstTab must exists and can be at least zero therefore indexofSecondTab can be at least one.
				if (indexofSecondTab>0)
					high = Integer.parseInt(strLine.substring(indexofSecondTab+1));
				else 
					high = low;
				
				Interval interval = new Interval(low,high);
//				todo
//				bufferedWriter.write("Searched for" + "\t" + chromName + "\t" + low + "\t" + high + "\n");
//				bufferedWriter.flush();				
				ucscRefSeqGenesIntervalTree.findAllOverlappingUcscRefSeqGenesIntervals(ucscRefSeqGenesIntervalTree.getRoot(),interval,chromName,bufferedWriterHashMap,nameorIdHashMap,type);
				
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} // End of while 
	}
	
	

	

	public BufferedReader createBufferedReader(String fileName){
		FileReader fileReader = null;
		BufferedReader bufferedReader = null;
		
		try {
			fileReader = new FileReader(fileName);
			bufferedReader = new BufferedReader(fileReader);
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		
		return bufferedReader;
	}
	
	
	public void fillList(List<String> list, String inputFileName){
		String strLine;
		FileReader fileReader = null;
		BufferedReader bufferedReader = null;
		
		try {
			fileReader = new FileReader(inputFileName);			
			bufferedReader = new BufferedReader(fileReader);
			
			while((strLine = bufferedReader.readLine())!=null) {			
				list.add(strLine);
				strLine = null;
			}
			
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		try {
			bufferedReader.close();
			fileReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}			
	}

	
	public void fillHashMap(Map<String,Integer> hashMap, String inputFileName){
		String strLine;
		FileReader fileReader = null;
		BufferedReader bufferedReader = null;
		
		try {
			fileReader = new FileReader(inputFileName);			
			bufferedReader = new BufferedReader(fileReader);
			
			while((strLine = bufferedReader.readLine())!=null) {
				hashMap.put(strLine, Commons.ZERO);
				
				strLine = null;
			}
			
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		try {
			bufferedReader.close();
			fileReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}			
	}
	
	public void writeResults(String type, Map<String,Integer> hashMap, String outputFileName){
		FileWriter fileWriter;
		BufferedWriter  bufferedWriter;
		try {
			fileWriter = new FileWriter(outputFileName);
			bufferedWriter = new BufferedWriter(fileWriter);
		
		
			Set<Map.Entry<String,Integer>> set = hashMap.entrySet();
			Iterator<Map.Entry<String,Integer>> itr = set.iterator();
			
		
			while(itr.hasNext()){
				Map.Entry<String, Integer>	 entry = (Map.Entry<String, Integer>) itr.next();
				if (Commons.DNASE.equals(type)){
					bufferedWriter.write(entry.getKey() + "\t" + entry.getValue() + "\n");
				}else if (Commons.TFBS.equals(type)){
					bufferedWriter.write(entry.getKey() + "\t" + entry.getValue() + "\n");
				}else if (Commons.HISTONE.equals(type)){
					bufferedWriter.write(entry.getKey() + "\t" + entry.getValue() + "\n");
				}else if (Commons.NCBI_GENE_ID.equals(type)){
					bufferedWriter.write(entry.getKey() + "\t" + entry.getValue() + "\n");
				}else if (Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION.equals(type)){
					bufferedWriter.write(entry.getKey() + "\t" + entry.getValue() + "\n");
				}else if (Commons.UCSC_GENE_ALTERNATE_NAME.equals(type)){
					bufferedWriter.write(entry.getKey() + "\t" + entry.getValue() + "\n");
				}else if (Commons.KEGG_PATHWAY.equals(type)){
					bufferedWriter.write(entry.getKey() + "\t" + entry.getValue() + "\n");
				}	
			}
			
			bufferedWriter.close();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}
	
	public void convertKeggPathway2NcbiGeneIdList(String givenKeggPathwayName, String keggPathway2NcbiGeneIdsInputFileName, List<String> keggPathway2NcbiGeneIdsList){
		String strLine;
		FileReader fileReader = null;
		BufferedReader bufferedReader = null;
		
		int indexofFirstTab 	= -1;
		int indexofSecondTab 	= -1;
		int indexofFirstColon 		= -1;
		int indexofSecondColon 		= -1;
		
		String keggPathwayName;
		String ncbiGeneId;
		
		try {
			fileReader = new FileReader(keggPathway2NcbiGeneIdsInputFileName);
			bufferedReader = new BufferedReader(fileReader);
			
			while((strLine = bufferedReader.readLine())!=null){

				indexofFirstTab 	= strLine.indexOf('\t');
				indexofSecondTab 	= strLine.indexOf('\t',indexofFirstTab+1);
				
				keggPathwayName 	= strLine.substring(0,indexofFirstTab);
				indexofFirstColon 	= keggPathwayName.indexOf(':');
				keggPathwayName 	= keggPathwayName.substring(indexofFirstColon+1);								
				
				if(givenKeggPathwayName.equals(keggPathwayName)){
					
					ncbiGeneId = strLine.substring(indexofFirstTab+1,indexofSecondTab);
					indexofSecondColon = ncbiGeneId.indexOf(':');					
					ncbiGeneId = ncbiGeneId.substring(indexofSecondColon+1);
					 
//					Add only unique ncbi gene id 
					if(!(keggPathway2NcbiGeneIdsList.contains(ncbiGeneId))){
						keggPathway2NcbiGeneIdsList.add(ncbiGeneId);
					}				
				}																
			} // End of While
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		try {
			bufferedReader.close();
			fileReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}	
	}

	
	public void fillKeggPathwayList(List<KeggPathway> keggPathwayList, Map<String,Integer> keggPathwayNameHashMap){
		String keggPathwayName = null;
		
		// assumption keggPathwayNameList contains unique kegg Pathway names
		Set<String> keggPathwayNameSet = keggPathwayNameHashMap.keySet();
		Iterator<String> itr = keggPathwayNameSet.iterator();
		
		while (itr.hasNext()){
			keggPathwayName = (String)itr.next();
			List<String> keggPathway2NcbiGeneIdsList = new ArrayList<String>();			
			keggPathway2NcbiGeneIdsList.clear();
			convertKeggPathway2NcbiGeneIdList(keggPathwayName, Commons.KEGG_PATHWAY_2_NCBI_GENE_IDS_INPUT_FILE, keggPathway2NcbiGeneIdsList);
			
			KeggPathway keggPathway = new KeggPathway(keggPathwayName, keggPathway2NcbiGeneIdsList);
			
			keggPathwayList.add(keggPathway);			

		}
	}
	
		

	public void fillKeggPathway2NcbiGeneIdList(Map<String,Integer> keggPathwayNameHashMap, String keggPathway2NcbiGeneIdsInputFileName, List<String> allKeggPathways2NcbiGeneIdsList){
		String strLine;
		FileReader fileReader = null;
		BufferedReader bufferedReader = null;
		
		int indexofFirstTab 	= -1;
		int indexofSecondTab 	= -1;
		int indexofFirstColon 		= -1;
		int indexofSecondColon 		= -1;
		
		String keggPathwayName;
		String ncbiGeneId;
		
		try {
			fileReader = new FileReader(keggPathway2NcbiGeneIdsInputFileName);
			bufferedReader = new BufferedReader(fileReader);
			
			while((strLine = bufferedReader.readLine())!=null){

				indexofFirstTab 	= strLine.indexOf('\t');
				indexofSecondTab 	= strLine.indexOf('\t',indexofFirstTab+1);
				
				keggPathwayName 	= strLine.substring(0,indexofFirstTab);
				indexofFirstColon 	= keggPathwayName.indexOf(':');
				keggPathwayName 	= keggPathwayName.substring(indexofFirstColon+1);				
				
				
				if(keggPathwayNameHashMap.containsKey(keggPathwayName)){
					
					ncbiGeneId = strLine.substring(indexofFirstTab+1,indexofSecondTab);
					indexofSecondColon = ncbiGeneId.indexOf(':');					
					ncbiGeneId = ncbiGeneId.substring(indexofSecondColon+1);
					 
//					Add only unique ncbi gene id 
					if(!(allKeggPathways2NcbiGeneIdsList.contains(ncbiGeneId))){
						allKeggPathways2NcbiGeneIdsList.add(ncbiGeneId);
					}				
				}																
			} // End of While
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		try {
			bufferedReader.close();
			fileReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}	
	}
	
	
	public void closeBufferedWriterList(List<BufferedWriter> bufferedWriterList){
		BufferedWriter bufferedWriter = null;
		try {			
			for(int i = 0; i<bufferedWriterList.size(); i++){			
				bufferedWriter = bufferedWriterList.get(i);				
				bufferedWriter.close();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	
	
	
	public void closeBufferedWriters(Map<String,BufferedWriter> hashMap) {
		Iterator<BufferedWriter> itr = hashMap.values().iterator();
		while(itr.hasNext()){
			try {
				((BufferedWriter)itr.next()).close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}		
	}
	
	
	public void searchDnase(Map<String,Integer> dnaseCellLineNameHashMap) {
		
		BufferedReader bufferedReader =null ;
				
		IntervalTree dnaseIntervalTree;
			
		Map<String,BufferedWriter> dnaseBufferedWriterHashMap = new HashMap<String,BufferedWriter>(); 
		
		for(int i = 1; i<=24 ; i++ ){
			
			switch(i){
				case 1:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME1,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR1_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME1,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());				
					dnaseIntervalTree = null;
			
					break;
				case 2:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME2,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR2_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME2,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());	
					dnaseIntervalTree = null;
					
					break;
				case 3:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME3,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR3_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME3,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;

					break;
				case 4:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME4,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR4_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME4,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;		
					
					break;
				case 5:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME5,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR5_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME5,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;

				
					break;
				case 6:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME6,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR6_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME6,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
			
					
					break;
				case 7:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME7,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR7_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME7,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
				
					break;
				case 8:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME8,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR8_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME8,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
					
					break;
				case 9	:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME9,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR9_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME9,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;

					break;
				case 10:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME10,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR10_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME10,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());	
					dnaseIntervalTree = null;
				
					break;
				case 11:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME11,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR11_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME11,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
	
					
					break;
				case 12:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME12,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR12_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME12,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
	
					break;
				case 13:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME13,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR13_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME13,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
					
					break;
				case 14:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME14,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR14_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME14,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
					
					break;
				case 15:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME15,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR15_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME15,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
					
					break;
				case 16:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME16,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR16_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME16,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
					
					break;
				case 17:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME17,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR17_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME17,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
				
					break;
				case 18:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME18,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR18_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME18,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
						
					break;
				case 19:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME19,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR19_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME19,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
					
					break;
				case 20:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME20,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR20_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME20,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
				
					
					break;
				case 21:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME21,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR21_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME21,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
				
					break;
				case 22:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOME22,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR22_INPUT_FILE);
					searchDnase(Commons.CHROMOSOME22,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
				
					
					break;
				case 23:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOMEX,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHRX_INPUT_FILE);
					searchDnase(Commons.CHROMOSOMEX,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
					
					break;
				case 24:							
					dnaseIntervalTree = createDnaseIntervalTree(Commons.CHROMOSOMEY,dnaseCellLineNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHRY_INPUT_FILE);
					searchDnase(Commons.CHROMOSOMEY,bufferedReader, dnaseIntervalTree, dnaseBufferedWriterHashMap,dnaseCellLineNameHashMap);
					emptyIntervalTree(dnaseIntervalTree.getRoot());					
					dnaseIntervalTree = null;
					
					break;
					
				}//end of Swicth
		}//end of For
		
		closeBufferedWriters(dnaseBufferedWriterHashMap);	
		
		try {
			bufferedReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}



	public void searchTfbs(Map<String,Integer> tfbsNameHashMap) {
		
		BufferedReader bufferedReader =null ;
				
		IntervalTree tfbsIntervalTree;
		
		Map<String,BufferedWriter> tfbsBufferedWriterHashMap = new HashMap<String,BufferedWriter>(); 
		
		for(int i = 1; i<=24 ; i++ ){
			
			switch(i){
				case 1:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME1,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR1_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME1,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					
					break;
				case 2:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME2,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR2_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME2,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

				
						break;
				case 3:							
	
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME3,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR3_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME3,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

						break;
				case 4:							
			
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME4,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR4_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME4,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					
					break;
				case 5:							

					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME5,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR5_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME5,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

	
					break;
				case 6:							
	
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME6,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR6_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME6,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					break;
				case 7:							

					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME7,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR7_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME7,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					
					break;
				case 8:							
														
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME8,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR8_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME8,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					
					break;
				case 9	:							
	
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME9,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR9_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME9,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					break;
				case 10:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME10,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR10_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME10,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					
					break;
				case 11:							
						
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME11,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR11_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME11,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;


					
					break;
				case 12:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME12,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR12_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME12,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					break;
				case 13:							
				
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME13,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR13_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME13,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					
					break;
				case 14:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME14,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR14_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME14,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					
					break;
				case 15:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME15,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR15_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME15,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

				
					break;
				case 16:							
				
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME16,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR16_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME16,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;


					break;
				case 17:							
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME17,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR17_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME17,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					
					break;
				case 18:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME18,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR18_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME18,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;

					break;
				case 19:							
						
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME19,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR19_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME19,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;
					
					break;
				case 20:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME20,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR20_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME20,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;
					
					break;
				case 21:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME21,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR21_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME21,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;
					
					break;
				case 22:							
				
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOME22,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR22_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOME22,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;
				
					break;
				case 23:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOMEX,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHRX_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOMEX,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;
						
					break;
				case 24:							
					
					tfbsIntervalTree = createTfbsIntervalTree(Commons.CHROMOSOMEY,tfbsNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHRY_INPUT_FILE);
					searchTfbs(Commons.CHROMOSOMEY,bufferedReader, tfbsIntervalTree, tfbsBufferedWriterHashMap, tfbsNameHashMap);
					emptyIntervalTree(tfbsIntervalTree.getRoot());
					tfbsIntervalTree = null;
					
					break;
					
				}//end of Swicth
		}//end of For
		
		closeBufferedWriters(tfbsBufferedWriterHashMap);
		
		try {
			bufferedReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	

	public void searchHistone(Map<String,Integer> histoneNameHashMap) {
		
		BufferedReader bufferedReader =null ;
				
		IntervalTree histoneIntervalTree;
		
		Map<String,BufferedWriter> histoneBufferedWriterHashMap = new HashMap<String,BufferedWriter>(); 				
		
		for(int i = 1; i<=24 ; i++ ){
			
			switch(i){
				case 1:							
		
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME1,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR1_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME1,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 2:							
					
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME2,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR2_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME2,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
						break;
				case 3:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME3,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR3_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME3,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;

						break;
				case 4:							
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME4,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR4_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME4,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 5:							
				
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME5,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR5_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME5,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;

					break;
				case 6:							
					
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME6,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR6_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME6,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 7:							
				
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME7,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR7_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME7,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 8:							
				
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME8,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR8_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME8,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 9	:							
		
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME9,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR9_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME9,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;

					break;
				case 10:							
		
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME10,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR10_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME10,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 11:							
		
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME11,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR11_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME11,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;

					
					break;
				case 12:							
	
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME12,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR12_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME12,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;

					break;
				case 13:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME13,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR13_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME13,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 14:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME14,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR14_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME14,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 15:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME15,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR15_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME15,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 16:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME16,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR16_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME16,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					

					break;
				case 17:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME17,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR17_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME17,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 18:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME18,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR18_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME18,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 19:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME19,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR19_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME19,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 20:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME20,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR20_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME20,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 21:							
					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME21,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR21_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME21,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 22:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOME22,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR22_INPUT_FILE);
					searchHistone(Commons.CHROMOSOME22,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 23:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOMEX,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHRX_INPUT_FILE);
					searchHistone(Commons.CHROMOSOMEX,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
				case 24:							

					histoneIntervalTree = createHistoneIntervalTree(Commons.CHROMOSOMEY,histoneNameHashMap);
					bufferedReader = createBufferedReader(Commons.SEARCH_CHRY_INPUT_FILE);
					searchHistone(Commons.CHROMOSOMEY,bufferedReader, histoneIntervalTree, histoneBufferedWriterHashMap, histoneNameHashMap);
					emptyIntervalTree(histoneIntervalTree.getRoot());
					histoneIntervalTree = null;
					
					break;
					
				}//end of Swicth
		}//end of For
		
		closeBufferedWriters(histoneBufferedWriterHashMap);
		
		try {
			bufferedReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}


public void searchNcbiGeneId(Map<String,Integer> ncbiGeneIdHashMap) {
		
		BufferedReader bufferedReader =null ;
				
		IntervalTree geneIntervalTree;
		
		Map<String,BufferedWriter> ncbiGeneIdBufferedWriterHashMap = new HashMap<String,BufferedWriter>(); 
		
		
		for(int i = 1; i<=24 ; i++ ){
			
			switch(i){
				case 1:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME1);

					bufferedReader = createBufferedReader(Commons.SEARCH_CHR1_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME1,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
										
					emptyIntervalTree(geneIntervalTree.getRoot());
					geneIntervalTree = null;
					System.out.println("Chr1 NcbiGeneId");
					break;
				case 2:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME2);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR2_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME2,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());
					geneIntervalTree = null;
					System.out.println("Chr2 NcbiGeneId");

					break;
				case 3:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME3);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR3_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME3,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());
					geneIntervalTree = null;
					System.out.println("Chr3  NcbiGeneId");

					break;
				case 4:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME4);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR4_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME4,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr4  NcbiGeneId");

					break;
				case 5:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME5);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR5_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME5,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr5 NcbiGeneId");

					break;
				case 6:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME6);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR6_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME6,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr6 NcbiGeneId");

					break;
				case 7:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME7);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR7_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME7,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr7 NcbiGeneId");

					break;
				case 8:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME8);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR8_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME8,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr8 NcbiGeneId");

					break;
				case 9	:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME9);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR9_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME9,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr9 NcbiGeneId");

					break;
				case 10:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME10);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR10_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME10,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr10 NcbiGeneId");

					break;
				case 11:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME11);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR11_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME11,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr11 NcbiGeneId");
					
					break;
				case 12:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME12);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR12_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME12,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr12 NcbiGeneId");

					break;
				case 13:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME13);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR13_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME13,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr13 NcbiGeneId");

					break;
				case 14:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME14);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR14_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME14,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr14 NcbiGeneId");

					break;
				case 15:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME15);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR15_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME15,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr15 NcbiGeneId");

					break;
				case 16:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME16);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR16_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME16,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr16 NcbiGeneId");

					break;
				case 17:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME17);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR17_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME17,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);

					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr17 NcbiGeneId");

					break;
				case 18:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME18);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR18_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME18,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr18 NcbiGeneId");

					break;
				case 19:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME19);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR19_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME19,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr19 NcbiGeneId");

					break;
				case 20:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME20);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR20_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME20,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr20 NcbiGeneId");

					break;
				case 21:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME21);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR21_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME21,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr21 NcbiGeneId");

					break;
				case 22:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME22);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHR22_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOME22,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr22 NcbiGeneId");
					
					break;
				case 23:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOMEX);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHRX_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOMEX,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);
					
					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr23 NcbiGeneId");

					break;
				case 24:							
					geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOMEY);
					
					bufferedReader = createBufferedReader(Commons.SEARCH_CHRY_INPUT_FILE);
					searchUcscRefSeqGenes(Commons.CHROMOSOMEY,bufferedReader, geneIntervalTree, ncbiGeneIdBufferedWriterHashMap, ncbiGeneIdHashMap, Commons.NCBI_GENE_ID);

					emptyIntervalTree(geneIntervalTree.getRoot());								
					geneIntervalTree = null;
					System.out.println("Chr24 NcbiGeneId");
			
					break;
					
				}//end of Swicth
		}//end of For
		
		closeBufferedWriters(ncbiGeneIdBufferedWriterHashMap);
	
		try {
			bufferedReader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}




public void searchNcbiRNANucleotideAccessionVersion(Map<String,Integer> ncbiRnaNucleotideAccessionVersionHashMap) {
	
	BufferedReader bufferedReader =null ;
			
	IntervalTree geneIntervalTree;
	
	Map<String,BufferedWriter> ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap = new HashMap<String,BufferedWriter>(); 
	
	
	for(int i = 1; i<=24 ; i++ ){
		
		switch(i){
			case 1:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME1);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR1_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME1,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);

				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr1 NcbiRNA");
				break;
			case 2:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME2);

				bufferedReader = createBufferedReader(Commons.SEARCH_CHR2_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME2,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);

				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr2 NcbiRNA");

				break;
			case 3:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME3);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR3_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME3,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);

				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr3 NcbiRNA");

				break;
			case 4:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME4);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR4_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME4,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr4 NcbiRNA");

				break;
			case 5:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME5);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR5_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME5,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr5 NcbiRNA");

				break;
			case 6:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME6);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR6_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME6,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr6 NcbiRNA");

				break;
			case 7:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME7);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR7_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME7,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr7 NcbiRNA");

				break;
			case 8:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME8);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR8_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME8,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr8 NcbiRNA");

				break;
			case 9	:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME9);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR9_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME9,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr9 NcbiRNA");

				break;
			case 10:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME10);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR10_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME10,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr10 NcbiRNA");

				break;
			case 11:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME11);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR11_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME11,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr11 NcbiRNA");
				
				break;
			case 12:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME12);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR12_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME12,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr12 NcbiRNA");

				break;
			case 13:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME13);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR13_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME13,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr13 NcbiRNA");

				break;
			case 14:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME14);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR14_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME14,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr14 NcbiRNA");

				break;
			case 15:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME15);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR15_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME15,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr15 NcbiRNA");

				break;
			case 16:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME16);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR16_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME16,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr16 NcbiRNA");

				break;
			case 17:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME17);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR17_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME17,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr17 NcbiRNA");

				break;
			case 18:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME18);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR18_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME18,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr18 NcbiRNA");

				break;
			case 19:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME19);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR19_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME19,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr19 NcbiRNA");

				break;
			case 20:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME20);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR20_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME20,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr20 NcbiRNA");

				break;
			case 21:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME21);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR21_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME21,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr21 NcbiRNA");

				break;
			case 22:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME22);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR22_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME22,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr22 NcbiRNA");
				
				break;
			case 23:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOMEX);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHRX_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOMEX,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr23 NcbiRNA");

				break;
			case 24:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOMEY);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHRY_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOMEY,bufferedReader, geneIntervalTree, ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap, ncbiRnaNucleotideAccessionVersionHashMap, Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr24 NcbiRNA");
		
				break;
				
			}//end of Swicth
	}//end of For
	
	closeBufferedWriters(ncbiRnaNucleotideAccessionVersionBufferedWriterHashMap);
	
	try {
		bufferedReader.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	
}


public void searchUcscGeneAlternateName(Map<String,Integer>  ucscGeneAlternateNameHashMap) {
	
	BufferedReader bufferedReader =null ;
			
	IntervalTree geneIntervalTree;
	
	Map<String,BufferedWriter> ucscGeneAlternateNameBufferedWriterHashMap = new HashMap<String,BufferedWriter>();		
	
	
	for(int i = 1; i<=24 ; i++ ){
		
		switch(i){
			case 1:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME1);

				bufferedReader = createBufferedReader(Commons.SEARCH_CHR1_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME1,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr1 UcscGeneAlternateName");
				break;
			case 2:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME2);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR2_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME2,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
									
				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr2 UcscGeneAlternateName");

				break;
			case 3:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME3);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR3_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME3,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr3 UcscGeneAlternateName");

				break;
			case 4:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME4);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR4_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME4,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr4 UcscGeneAlternateName");

				break;
			case 5:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME5);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR5_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME5,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
									
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr5 UcscGeneAlternateName");

				break;
			case 6:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME6);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR6_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME6,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr6 UcscGeneAlternateName");

				break;
			case 7:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME7);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR7_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME7,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr7 UcscGeneAlternateName");

				break;
			case 8:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME8);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR8_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME8,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr8 UcscGeneAlternateName");

				break;
			case 9	:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME9);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR9_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME9,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr9 UcscGeneAlternateName");

				break;
			case 10:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME10);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR10_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME10,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr10 UcscGeneAlternateName");

				break;
			case 11:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME11);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR11_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME11,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr11 UcscGeneAlternateName");
				
				break;
			case 12:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME12);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR12_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME12,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr12 UcscGeneAlternateName");

				break;
			case 13:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME13);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR13_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME13,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr13 UcscGeneAlternateName");

				break;
			case 14:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME14);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR14_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME14,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr14 UcscGeneAlternateName");

				break;
			case 15:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME15);
				
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR15_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME15,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr15 UcscGeneAlternateName");

				break;
			case 16:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME16);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR16_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME16,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr16 UcscGeneAlternateName");

				break;
			case 17:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME17);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR17_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME17,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr17 UcscGeneAlternateName");

				break;
			case 18:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME18);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR18_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME18,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr18 UcscGeneAlternateName");

				break;
			case 19:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME19);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR19_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME19,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
									
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr19 UcscGeneAlternateName");

				break;
			case 20:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME20);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR20_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME20,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr20 UcscGeneAlternateName");

				break;
			case 21:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME21);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR21_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME21,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
									
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr21 UcscGeneAlternateName");

				break;
			case 22:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME22);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR22_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME22,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr22 UcscGeneAlternateName");
				
				break;
			case 23:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOMEX);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHRX_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOMEX,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr23 UcscGeneAlternateName");

				break;
			case 24:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOMEY);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHRY_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOMEY,bufferedReader, geneIntervalTree, ucscGeneAlternateNameBufferedWriterHashMap, ucscGeneAlternateNameHashMap,Commons.UCSC_GENE_ALTERNATE_NAME);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr24 UcscGeneAlternateName");
		
				break;
				
			}//end of Swicth
	}//end of For
	
	closeBufferedWriters(ucscGeneAlternateNameBufferedWriterHashMap);
	
	try {
		bufferedReader.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	
}


public void searchKeggPathway(Map<String,Integer> keggPathwayNameHashMap, List<KeggPathway> keggPathwayList, List<String> allKeggPathways2NcbiGeneIdsList) {
	
	BufferedReader bufferedReader =null ;
			
	IntervalTree geneIntervalTree;
	
	Map<String,BufferedWriter> keggPathwayBufferedWriterHashMap = new HashMap<String,BufferedWriter>();
	
	
	for(int i = 1; i<=24 ; i++ ){
		
		switch(i){
			case 1:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME1);

				bufferedReader = createBufferedReader(Commons.SEARCH_CHR1_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME1,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);
				
				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr1 KeggPathway");
				break;
			case 2:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME2);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR2_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME2,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap,keggPathwayNameHashMap, keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);
				
				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr2 KeggPathway");

				break;
			case 3:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME3);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR3_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME3,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());
				geneIntervalTree = null;
				System.out.println("Chr3 KeggPathway");

				break;
			case 4:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME4);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR4_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME4,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap,keggPathwayNameHashMap, keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr4 KeggPathway");

				break;
			case 5:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME5);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR5_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME5,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr5 KeggPathway");

				break;
			case 6:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME6);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR6_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME6,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr6 KeggPathway");

				break;
			case 7:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME7);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR7_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME7,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap,keggPathwayNameHashMap, keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr7 KeggPathway");

				break;
			case 8:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME8);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR8_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME8,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr8 KeggPathway");

				break;
			case 9	:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME9);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR9_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME9,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap,keggPathwayNameHashMap, keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr9 KeggPathway");

				break;
			case 10:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME10);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR10_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME10,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr10 KeggPathway");

				break;
			case 11:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME11);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR11_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME11,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap,keggPathwayNameHashMap, keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr11 KeggPathway");
				
				break;
			case 12:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME12);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR12_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME12,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr12 KeggPathway");

				break;
			case 13:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME13);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR13_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME13,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr13 KeggPathway");

				break;
			case 14:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME14);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR14_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME14,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap,keggPathwayNameHashMap, keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr14 KeggPathway");

				break;
			case 15:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME15);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR15_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME15,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr15 KeggPathway");

				break;
			case 16:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME16);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR16_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME16,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr16 KeggPathway");

				break;
			case 17:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME17);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR17_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME17,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr17 KeggPathway");

				break;
			case 18:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME18);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR18_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME18,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr18 KeggPathway");

				break;
			case 19:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME19);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR19_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME19,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr19 KeggPathway");

				break;
			case 20:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME20);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR20_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME20,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr20 KeggPathway");

				break;
			case 21:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME21);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR21_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME21,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr21 KeggPathway");

				break;
			case 22:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOME22);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHR22_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOME22,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr22 KeggPathway");
				
				break;
			case 23:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOMEX);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHRX_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOMEX,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);
				
				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr23 KeggPathway");

				break;
			case 24:							
				geneIntervalTree = createUcscRefSeqGenesIntervalTree(Commons.CHROMOSOMEY);
				
				bufferedReader = createBufferedReader(Commons.SEARCH_CHRY_INPUT_FILE);
				searchUcscRefSeqGenes(Commons.CHROMOSOMEY,bufferedReader, geneIntervalTree, keggPathwayBufferedWriterHashMap, keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList, Commons.NCBI_GENE_ID);

				emptyIntervalTree(geneIntervalTree.getRoot());								
				geneIntervalTree = null;
				System.out.println("Chr24 KeggPathway");
		
				break;
				
			}//end of Swicth
	}//end of For
	
	closeBufferedWriters(keggPathwayBufferedWriterHashMap);
	
	try {
		bufferedReader.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	
}


	public void emptyIntervalTree(IntervalTreeNode node){
		if(node!=null){
			emptyIntervalTree(node.getRight());
			emptyIntervalTree(node.getLeft());
			
			if(node.getCellLineName()!=null){
				node.setCellLineName(null);
			}
			
			if(node.getFileName()!=null){
				node.setFileName(null);
			}
			
			if(node.getTfbsorHistoneName()!=null){
				node.setTfbsorHistoneName(null);
			}
			
			if(node.getGeneHugoSymbol()!=null){
				node.setGeneHugoSymbol(null);
			}
			
			if(node.getIntervalName()!=null){
				node.setIntervalName(null);
			}
			
			if(node.getGeneEntrezId()!=null){
				node.setGeneEntrezId(null);
			}
			
			if(node.getRefSeqGeneName()!=null){
				node.setRefSeqGeneName(null);
			}
			
			if(node.getChromName()!=null){
				node.setChromName(null);
			}
			
			if (node.getLeft()!=null) {
				node.setLeft(null);
			}

			if (node.getRight()!=null) {
				node.setRight(null);
			}

			if (node.getParent()!=null) {
				node.setParent(null);
			}

			node = null;
		}		
	}
	


	public static void main(String[] args) {
		AnnotateGivenIntervalsWithGivenParameters annotateIntervals = new AnnotateGivenIntervalsWithGivenParameters();
		
		//Prepare chromosome based partitioned input interval files to be searched for
		List<BufferedWriter> bufferedWriterList = new ArrayList<BufferedWriter>();	
		annotateIntervals.createChromBaseSeachInputFiles(bufferedWriterList);		
//		annotateIntervals.partitionSearchInputFilePerChromName(Commons.ANNOTATE_INTERVALS_USING_INTERVAL_TREE_REGULOMEDB_EXAMPLE_INPUT_FILE,bufferedWriterList);
		annotateIntervals.partitionSearchInputFilePerChromName(Commons.ANNOTATE_INTERVALS_USING_INTERVAL_TREE_INPUT_FILE,bufferedWriterList);
		annotateIntervals.closeBufferedWriterList(bufferedWriterList);					
		
		//Search input interval files for dnase 
		Map<String,Integer> dnaseCellLineNameHashMap = new HashMap<String,Integer>();
		
//		annotateIntervals.fillHashMap(dnaseCellLineNameHashMap,Commons.ANNOTATE_INTERVALS_WITH_DNASE_USING_INTERVAL_TREE_INPUT_FILE);
		annotateIntervals.fillHashMap(dnaseCellLineNameHashMap,Commons.WRITE_ALL_POSSIBLE_DNASE_CELL_NAMES_OUTPUT_FILE);		
		annotateIntervals.searchDnase(dnaseCellLineNameHashMap);	
		annotateIntervals.writeResults(Commons.DNASE,dnaseCellLineNameHashMap, Commons.ANNOTATE_INTERVALS_DNASE_RESULTS_OUTPUT_FILE);
		//Free space
		dnaseCellLineNameHashMap.clear();
		dnaseCellLineNameHashMap = null;
		
		//Search input interval files for tfbs 		
		Map<String,Integer> tfbsNameHashMap = new HashMap<String,Integer>();
//		annotateIntervals.fillHashMap(tfbsNameHashMap,Commons.ANNOTATE_INTERVALS_WITH_TFBS_USING_INTERVAL_TREE_INPUT_FILE);
		annotateIntervals.fillHashMap(tfbsNameHashMap,Commons.WRITE_ALL_POSSIBLE_TFBS_NAMES_OUTPUT_FILE);		
		annotateIntervals.searchTfbs(tfbsNameHashMap);		
		annotateIntervals.writeResults(Commons.TFBS,tfbsNameHashMap, Commons.ANNOTATE_INTERVALS_TFBS_RESULTS_OUTPUT_FILE);
		//Free space
		tfbsNameHashMap.clear();
		tfbsNameHashMap = null;
		
		//Search input interval files for histone 		
		Map<String,Integer> histoneNameHashMap = new HashMap<String,Integer>();		
//		annotateIntervals.fillHashMap(histoneNameHashMap,Commons.ANNOTATE_INTERVALS_WITH_HISTONE_USING_INTERVAL_TREE_INPUT_FILE);
		annotateIntervals.fillHashMap(histoneNameHashMap,Commons.WRITE_ALL_POSSIBLE_HISTONE_NAMES_OUTPUT_FILE);
		annotateIntervals.searchHistone(histoneNameHashMap);
		annotateIntervals.writeResults(Commons.HISTONE,histoneNameHashMap, Commons.ANNOTATE_INTERVALS_HISTONE_RESULTS_OUTPUT_FILE);
		//Free space		
		histoneNameHashMap.clear();
		histoneNameHashMap = null;
		
//		//search input interval files for ncbiGeneId		
//		Map<String,Integer> ncbiGeneIdHashMap = new HashMap<String,Integer>();		
//		annotateIntervals.fillHashMap(ncbiGeneIdHashMap,Commons.ANNOTATE_INTERVALS_WITH_NCBI_GENE_ID_USING_INTERVAL_TREE_INPUT_FILE);		
//		annotateIntervals.searchNcbiGeneId(ncbiGeneIdHashMap);
//		annotateIntervals.writeResults(Commons.NCBI_GENE_ID, ncbiGeneIdHashMap, Commons.ANNOTATE_INTERVALS_NCBI_GENE_ID_RESULTS_OUTPUT_FILE);
//		//Free space
//		ncbiGeneIdHashMap.clear();
//		ncbiGeneIdHashMap = null;
//		
//		//ncbiRna		
//		Map<String,Integer> ncbiRnaNucleotideAccessionVersionHashMap = new HashMap<String,Integer>();
//		annotateIntervals.fillHashMap(ncbiRnaNucleotideAccessionVersionHashMap,Commons.ANNOTATE_INTERVALS_WITH_NCBI_RNA_USING_INTERVAL_TREE_INPUT_FILE);
//		annotateIntervals.searchNcbiRNANucleotideAccessionVersion(ncbiRnaNucleotideAccessionVersionHashMap);
//		annotateIntervals.writeResults(Commons.NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION, ncbiRnaNucleotideAccessionVersionHashMap, Commons.ANNOTATE_INTERVALS_NCBI_RNA_NUCLEOTIDE_ACCESSION_VERSION_RESULTS_OUTPUT_FILE);
//		//Free space
//		ncbiRnaNucleotideAccessionVersionHashMap.clear();
//		ncbiRnaNucleotideAccessionVersionHashMap = null;
//		
//		//ucscGeneAlternateName
//		Map<String,Integer> ucscGeneAlternateNameHashMap = new HashMap<String,Integer>();
//		annotateIntervals.fillHashMap(ucscGeneAlternateNameHashMap,Commons.ANNOTATE_INTERVALS_WITH_UCSC_ALTERNATE_GENE_NAME_USING_INTERVAL_TREE_INPUT_FILE);			
//		annotateIntervals.searchUcscGeneAlternateName(ucscGeneAlternateNameHashMap);
//		annotateIntervals.writeResults(Commons.UCSC_GENE_ALTERNATE_NAME, ucscGeneAlternateNameHashMap, Commons.ANNOTATE_INTERVALS_UCSC_GENE_ALTERNATE_NAME_RESULTS_OUTPUT_FILE);
//		//Free space
//		ucscGeneAlternateNameHashMap.clear();
//		ucscGeneAlternateNameHashMap= null;
//		
//		//keggpathway
////		List<String> keggPathwayNameList = new ArrayList<String>();
//		Map<String,Integer> keggPathwayNameHashMap = new HashMap<String,Integer>();		
//		List<String> allKeggPathways2NcbiGeneIdsList = new ArrayList<String>();		
//		List<KeggPathway> keggPathwayList = new ArrayList<KeggPathway>();		
////		annotateIntervals.fillList(keggPathwayNameList,Commons.ANNOTATE_INTERVALS_WITH_KEGG_PATHWAY_USING_INTERVAL_TREE_INPUT_FILE);
//		annotateIntervals.fillHashMap(keggPathwayNameHashMap, Commons.ANNOTATE_INTERVALS_WITH_KEGG_PATHWAY_USING_INTERVAL_TREE_INPUT_FILE);		
//		annotateIntervals.fillKeggPathway2NcbiGeneIdList(keggPathwayNameHashMap, Commons.KEGG_PATHWAY_2_NCBI_GENE_IDS_INPUT_FILE, allKeggPathways2NcbiGeneIdsList);				
//		annotateIntervals.fillKeggPathwayList(keggPathwayList, keggPathwayNameHashMap);
//		annotateIntervals.searchKeggPathway(keggPathwayNameHashMap,keggPathwayList, allKeggPathways2NcbiGeneIdsList);
//		annotateIntervals.writeResults(Commons.KEGG_PATHWAY,keggPathwayNameHashMap, Commons.ANNOTATE_INTERVALS_KEGG_PATHWAY_RESULTS_OUTPUT_FILE);
//		
//		//Free space
//		keggPathwayNameHashMap.clear();
//		allKeggPathways2NcbiGeneIdsList.clear();
//		keggPathwayList.clear();
//		keggPathwayNameHashMap= null;
//		allKeggPathways2NcbiGeneIdsList = null;
//		keggPathwayList = null;
	}

}
			